<template>
  <div id="timeout">
    倒计时： {{timeout}}</div>
</template>

<script>
export default {
  name: "timeout",
  data() {
    return {
      timeout: ""
    };
  },
  methods: {},
  mounted() {
    const TIME_COUNT =this.$store.state.timer.timer;
    // if (!this.timer) {
      this.timeout = TIME_COUNT;
      this.timer = setInterval(() => {
        if (this.timeout > 0 && this.timeout <= TIME_COUNT) {
          this.timeout--;
        } else {
          clearInterval(this.timer);
          this.timer = null;
          //跳转的页面写在此处
          this.$store.dispatch('user/updateuserinfo', "");
          this.$router.push({ name: "home" });
        }
      }, 1000);
    // }
  },

};
</script>

<style scoped>
#timeout {
  color: red;
}
</style>>
